package com.gzhryc.net_marketing.cloud.business.dao;

import java.sql.SQLException;
import java.util.List;

import com.gzhryc.jdbc.BaseDao;
import com.gzhryc.jdbc.Conditions;
import com.gzhryc.jdbc.Query;
import com.gzhryc.net_marketing.cloud.business.dao.db.PayGoodsOrder;
import com.gzhryc.net_marketing.cloud.business.dao.models.TeamPayOrderStateCount;

public class PayGoodsOrderDao extends BaseDao<PayGoodsOrder> {

	public PayGoodsOrderDao(String jdbcKey) {
		super(jdbcKey);
	}

	public List<TeamPayOrderStateCount> countByGroupState(Conditions conditions) throws SQLException {
		String sql = "SELECT state,count(1) AS total FROM " + this.tableName;
		Query query = new Query(sql);
		query.appendSql(conditions.toSql(query.getParams(),true));
		query.appendSql(" GROUP BY state");
		return this.jdbcHelper.find(query, TeamPayOrderStateCount.class);
	}
}
